import { api, ApiResponse } from './client'
import { Sheet, Cell } from '@/types/sheet'

// 共享表格相关接口
export interface SharedSheetData {
  sheet: Sheet
  cells: Cell[]
}

// 共享表格相关 API
export const sharedApi = {
  // 获取共享的表格数据
  getSharedSheet: (shareToken: string): Promise<ApiResponse<SharedSheetData>> =>
    api.get(`/shared/${shareToken}`),

  // 更新共享表格的单元格
  updateSharedCell: (shareToken: string, data: { row: number; column: number; value: string }): Promise<ApiResponse<Cell>> =>
    api.put(`/shared/${shareToken}/cells`, data),

  // 更新共享表格的单元格样式
  updateSharedCellStyle: (shareToken: string, data: { row: number; column: number; style: any }): Promise<ApiResponse<Cell>> =>
    api.put(`/shared/${shareToken}/cells/style`, data),
}

export default sharedApi
